package com.geticsen.leetcode;

import java.util.ArrayList;
import java.util.List;
//https://leetcode-cn.com/problems/binary-tree-inorder-traversal/
public class Solution_94 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> result = new ArrayList<>();
        middleOrderTraversal(root, result);
        return result;
    }

    public void middleOrderTraversal(TreeNode node, List<Integer> result) {
        if (node == null) {
            return;
        }
        if (node.left != null) {
            middleOrderTraversal(node.left, result);
        }
        result.add(node.val);
        if (node.right != null) {
            middleOrderTraversal(node.right, result);
        }

    }
}
